from fastapi import Depends

from app.dependencies import Dependencies
from app.models.userModel import User


class userDao:

    def __init__(self, redis_client=Depends(Dependencies.get_redis), mongo_client=Depends(Dependencies.get_mongo)):
        self.redis_client = redis_client
        self.mongo_client = mongo_client

    @staticmethod
    async def get_user_by_id(user_id: int):
        """
        根据用户id获取用户信息
        """
        return await User.get_or_none(id=user_id)

    @staticmethod
    async def create_user(username: str, password: str, email: str):
        return await User.create(
            username=username,
            password=password,
            email=email,
        )
